<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>作业22</title>
    <script>
        /*
        用户输入一个数字n,计算。。。。
        */

        var num = prompt("请输入一个数字:");
        var numInt = parseInt(num)
        var sum = 0;

        for(var i=numInt; i>=2; i--){
            var tmp = (i+1)/i;
            sum += tmp;
        }

        alert("输入数字"+num+",计算结果是:"+sum);
    </script>
</head>
<body>
    
</body>
</html>